home *** CD-ROM | disk | FTP | other *** search
-
- #include <exec/types.h>
-
- #include <intuition/intuitionbase.h>
- #include <intuition/intuition.h>
- #include <intuition/screens.h>
- #include <graphics/clip.h>
- #include <devices/inputevent.h>
-
- #include <clib/intuition_protos.h>
- #include <clib/layers_protos.h>
-
- #include "ClickFront.h"
-
- extern struct IntuitionBase *IntuitionBase;
-
-
- void HandleClickToFront(struct InputEvent *ie)
- {
- static struct Window *win=0,*lastwin=0;
- static long secs=0,microsecs=0,count=0;
-
- win=WindowUnderPointer();
- if(InWindowBorder(win))
- {
- if((count==1) && (win==lastwin) && (DoubleClick(secs,microsecs,ie->ie_TimeStamp.tv_secs,ie->ie_TimeStamp.tv_micro)))
- {
- WindowToFront(win);
- count=0;
- }
- else
- {
- count=1; lastwin=win;
- secs=ie->ie_TimeStamp.tv_secs;
- microsecs=ie->ie_TimeStamp.tv_micro;
- }
- }
- }
-
-
- struct Window *WindowUnderPointer()
- {
- int x,y;
- unsigned long lock;
- struct Window *win=NULL;
- struct Screen *scr;
- struct Layer *layer;
-
- scr=IntuitionBase->FirstScreen;
- do
- {
- x=scr->MouseX; y=scr->MouseY;
- if((x<0) || (y<0))
- scr=scr->NextScreen;
- } while((scr!=NULL) && ((x<0)||(y<0)));
-
- if(!scr)
- return(NULL);
-
- layer=WhichLayer(&scr->LayerInfo,x,y);
- if(layer)
- win=layer->Window;
- return(win);
- }
-
-
- BOOL InWindowBorder(struct Window *win)
- {
- int x,y;
- if(!win)
- return(FALSE);
- x=win->MouseX; y=win->MouseY;
- if(x<win->BorderLeft)
- return(TRUE);
- if(y<win->BorderTop)
- return(TRUE);
- if(x>(win->Width-win->BorderRight-1))
- return(TRUE);
- if(y>(win->Height-win->BorderBottom-1))
- return(TRUE);
- return(FALSE);
- }
-
-